package com.example.music.controller;

import com.example.music.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/4/7 0007.
 */
@Controller
public class LoginController {

    @RequestMapping("login")
    public String login(Model model){
        model.addAttribute("user", new User());
        return "login";
    }
    @RequestMapping("")
    public String login1(Model model){
        model.addAttribute("user", new User());
        return "login";
    }

//    @RequestMapping(value = "loginValid",method = RequestMethod.POST)
//    public  @ResponseBody User index(@Valid User user, BindingResult result, Model model){
//
//        System.out.println(" user.getPassowrd()"+ user.getPassowrd()+":"+ user.getUserName());
//        if (result.hasErrors()) {
//            List<ObjectError> error = result.getAllErrors();
//            for (ObjectError e : error) {
//                System.out.println(e);
//            }
//            return null;
//        }
//        return user;
//    }

    @RequestMapping("index")
    public String index(Model model)
    {
        List list = new ArrayList();
        Map map = new HashMap();
        map.put("url","/index");
        return "index";
    }

    @RequestMapping("timeLog")
    public String timeLog(Model model)
    {
        return "timeLog";
    }



    public static void main(String[] args) {

    }

}
